from flask_restful import Api, Resource
from apis.user_api import UsersResource, UserResource
from apis.goods_api import GoodsResource, GoodsesResource

api = Api()


def init_api(app):
    api.init_app(app)


class HelloWorld(Resource):
    def get(self):
        # print(current_app.url_map)
        return {'Apis': 'Test flask_restful is OK!'}


api.add_resource(HelloWorld, '/api')

api.add_resource(UsersResource, '/api/users/')
api.add_resource(UserResource, '/api/user/<int:id>', endpoint='todo_ep')
api.add_resource(GoodsResource, '/api/goods/<int:id>', endpoint='single_goods')  # fields.Url(‘single_goods’) 要使用
api.add_resource(GoodsesResource, '/api/goodses')
